package com.bw.liuyushan.liuyushan20210929.MVP.Activity;

import android.Manifest;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.PermissionUtils;
import com.bw.liuyushan.liuyushan20210929.R;
import com.yzq.zxinglibrary.android.CaptureActivity;
import com.yzq.zxinglibrary.encode.CodeCreator;

/**
 * 二维码生成 二维码扫一扫 Zxing
 */
public class ZxingActivity extends AppCompatActivity {

    private ImageView imgZx;
    private Button lock;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zxing);
        initView();
        //动态权限获取
        PermissionUtils.permission(new String[]{
                Manifest.permission.CAMERA
        }).request();
        lock.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ZxingActivity.this, CaptureActivity.class);
                startActivity(intent);
            }
        });
        imgZx.setImageBitmap(CodeCreator.createQRCode("月考扫一扫",300,300,null));

    }

    private void initView() {

        imgZx = (ImageView) findViewById(R.id.img_zx);
        lock = (Button) findViewById(R.id.lock);

    }
}
